package com.example.tdj;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Scroller;
import android.widget.Spinner;
import android.widget.Toast;

import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.SDKInitializer;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationData;
import com.baidu.mapapi.model.LatLng;


public class MainActivity extends Activity implements View.OnClickListener,AdapterView.OnItemSelectedListener{
    private RelativeLayout relat1;
    private RelativeLayout relat2;
    private RelativeLayout relat3;
    private RelativeLayout relat4;
    private RelativeLayout relat5;
    private Button btrlt;
    private Spinner spinner1;
    private Spinner spinner2;

    public static int flag1 = 0;
    public static int flag2 = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        relat1 = findViewById(R.id.it1);
        relat2 = findViewById(R.id.it2);
        relat3 = findViewById(R.id.it3);
        relat4 = findViewById(R.id.it4);
        relat5 = findViewById(R.id.it5);
        btrlt = findViewById(R.id.btrlt);
        spinner1 = findViewById(R.id.sp1);
        spinner2 = findViewById(R.id.sp2);
        relat1.setOnClickListener(this);
        relat2.setOnClickListener(this);
        relat3.setOnClickListener(this);
        relat4.setOnClickListener(this);
        relat5.setOnClickListener(this);
        btrlt.setOnClickListener(this);
        spinner1.setOnItemSelectedListener(this);
        spinner2.setOnItemSelectedListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.it1:
            {
                Intent intent= new Intent();
                intent.setClass(MainActivity.this,Slip.class);
                startActivity(intent);
            }
            break;
            case R.id.it2:
                Intent intent2 = new Intent();
                intent2.setClass(MainActivity.this, ShowTrackActivity.class);
                startActivity(intent2);
                break;
            case R.id.it3:
                Toast.makeText(MainActivity.this,"我被点击了",Toast.LENGTH_SHORT).show();
                break;
            case R.id.it4:
                Toast.makeText(MainActivity.this,"我被点击了",Toast.LENGTH_SHORT).show();
                break;
            case R.id.it5:
                Toast.makeText(MainActivity.this,"我被点击了",Toast.LENGTH_SHORT).show();
                break;
            case R.id.btrlt:
            {
                Intent intent= new Intent();
                intent.setClass(MainActivity.this,HeatMap1.class);
                startActivity(intent);
            }

        }
    }

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        if(view.getId()==R.id.sp1)
        {
            switch (position){
                case 0:
                    flag1 = 0;
                    break;
                case 1:
                    flag1 = 15;
                    break;
                case 2:
                    flag1 =30;
                    break;
                case 3:
                    flag1 =45;
                    break;
                case 4:
                    flag1 =60;
                    break;
                case 5:
                    flag1 =75;
                    break;
                case 6:
                    flag1 =90;
                    break;
            }
        }
        else if(view.getId()== R.id.sp2)
        {
            switch (position){
                case 0:
                    flag2 = 0;
                    break;
                case 1:
                    flag2 = 1;
                    break;
                case 2:
                    flag2 =2;
                    break;
                case 3:
                    flag2 =3;
                    break;
                case 4:
                    flag2 =4;
                    break;
                case 5:
                    flag2 =5;
                    break;
                case 6:
                    flag2 =6;
                    break;
                case 7:
                    flag2 =7;
                    break;
                case 8:
                    flag2 =8;
                    break;
                case 9:
                    flag2 =9;
                    break;
                case 10:
                    flag2 =10;
                    break;
                case 11:
                    flag2 =11;
                    break;
                case 12:
                    flag2 =12;
                    break;
                case 13:
                    flag2 =13;
                    break;
                case 14:
                    flag2 =14;
                    break;
            }
        }


    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }

}
